// zh_gjw/pages/jishi/my.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    index: 0,
    activeIndex: 0,
    menu: ['进行中', '待付款'],
    list: [{}]
  },
  tabClick: function (e) {
    this.setData({
      activeIndex: e.currentTarget.dataset.index
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    app.location_attachurl(that)
    app.location_url(that)
    that.first()
    that.twice()
		var siteUrl = wx.getStorageSync('siteUrl')
    that.setData({
      siteUrl: siteUrl
    })
  },

  // 进行中数据
  first: function (e) {
    var that = this
    var openid = wx.getStorageSync('openid')
    app.util.request({
      url: 'entry/wxapp/Mymarketing',
      data: { openid: openid },
      success: function (res) {
        if (res.data.code == 200) {
          var array = res.data.res
          for (let i in array) {
            if (array[i].img != null) {
              array[i].img = array[i].img.split(',')
              that.setData({
                first: array
              })
            } else {
              that.setData({
                first: array
              })
            }
          }
          
        } else if (res.data.code == 500) {
          that.setData({
            first: [],
          })
        }
      }
    })
  },



  // 待付款
  twice: function (e) {
    var that = this
    var openid = wx.getStorageSync('openid')
    app.util.request({
      url: 'entry/wxapp/Mymarkettopays',
      data: {
        openid: openid
      },
      success: function (res) {
        if (res.data.code == 500) {
          that.setData({
            tlist: []
          })
        } else if (res.data.code == 200) {
          var array=res.data.res
          for (let i in array) {
            if (array[i].img != null) {
              array[i].img = array[i].img.split(',')              
              that.setData({
                tlist: array
              })
            } else {
              that.setData({
                tlist: array
              })
            }
          }
         
        }
      }
    })
  },       

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})